//构造
function aat(name) {
    this.name=name;
}

aat.prototype.hello=function () {
    alert('你好'+this.name)
}
//var aa=new aat('小明')
//console.log(aa.hello());

//class
class student{
    constructor(name){
this.name=name;
    }
    hello(){
        alert('你好'+this.name)
    }
}

var aas=new student('小红')
//console.log(aas.hello());

//class的继承
class primarystudent extends student{
    constructor(name){
        super(name)
    }
    hello(){
        alert('今天是礼拜'+this.name)
    }
}
var aax=new student('五')
//console.log(aax.hello());

class Animal {
    constructor(name) {
        this.name = name;
    }
}
class Cat extends Animal{
    constructor(name){
        super(name)
    }
    say(){
        return( "Hello, "+this.name+"!")
    }
}

// 测试:
var kitty = new Cat('Kitty');
var doraemon = new Cat('哆啦A梦');
if ((new Cat('x') instanceof Animal)
    && kitty 
    && kitty.name === 'Kitty'
    && kitty.say
    && typeof kitty.say === 'function'
    && kitty.say() === 'Hello, Kitty!'
    && kitty.say === doraemon.say)
{
    console.log('测试通过!');
} else {
    console.log('测试失败!');
}